import 'package:flutter/material.dart';
import 'package:vega/constant/constant.dart';
import 'package:vega/utils/common.dart';

import 'home_page.dart';
import 'search_page.dart';

class PlayerPage extends StatefulWidget {
  const PlayerPage({super.key});

  @override
  State<PlayerPage> createState() => _PlayerPageState();
}

class _PlayerPageState extends State<PlayerPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          const _MediaPlayer(),
          Expanded(
              child: ListView(
            padding:
                const EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10),
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  const Text(
                    Constant.text_tips,
                    style: TextStyle(fontSize: 18, color: Colors.pinkAccent),
                  ),
                  InkWell(
                    onTap: () => {showSnack(context, "追番")},
                    child: Container(
                      height: 28,
                      padding: const EdgeInsets.only(left: 10, right: 10),
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                          color: Colors.pinkAccent,
                          borderRadius: BorderRadius.circular(14)),
                      child: const Text("追番",
                          style: TextStyle(fontSize: 15, color: Colors.white)),
                    ),
                  ),
                ],
              ),
              const Padding(padding: EdgeInsets.only(top: 6)),
              const Text("类型：${Constant.text_tips}",
                  style: TextStyle(fontSize: 13.0, color: Colors.grey)),
              const Padding(padding: EdgeInsets.only(top: 6)),
              const Text("简介：${Constant.text_tips}",
                  style: TextStyle(fontSize: 13.0, color: Colors.grey)),
              const Padding(padding: EdgeInsets.only(top: 10)),
              const Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Text("选集",
                      style: TextStyle(fontSize: 18.0, color: Colors.black)),
                  Text(
                    "全24话 >",
                    style: TextStyle(fontSize: 13.0, color: Colors.grey),
                    textAlign: TextAlign.center,
                  ),
                ],
              ),
              const Padding(padding: EdgeInsets.only(top: 10)),
              SizedBox(
                height: 66,
                child: ListView.builder(
                  scrollDirection: Axis.horizontal,
                  itemCount: 6,
                  itemBuilder: (context, i) => InkWell(
                      onTap: () => showSnack(context, "点击选集"),
                      child: Row(
                        children: [
                          Container(
                            width: 130,
                            height: 66,
                            padding: const EdgeInsets.all(8),
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(8),
                                border:
                                    Border.all(width: 0.5, color: Colors.grey)),
                            child: const Text("第10话",
                                style: TextStyle(
                                    color: Colors.black, fontSize: 13)),
                          ),
                          const Padding(padding: EdgeInsets.only(left: 10))
                        ],
                      )),
                ),
              ),
              const Padding(padding: EdgeInsets.only(top: 10)),
              SizedBox(
                height: 26,
                child: ListView.builder(
                  scrollDirection: Axis.horizontal,
                  itemCount: 6,
                  itemBuilder: (context, i) => InkWell(
                      onTap: () => showSnack(context, "点击资源"),
                      child: Row(
                        children: [
                          Container(
                            padding: const EdgeInsets.only(left: 6, right: 6),
                            alignment: Alignment.center,
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(8),
                                border: Border.all(
                                    width: 0.5, color: Colors.pinkAccent)),
                            child: const Text("第10话",
                                style: TextStyle(
                                    color: Colors.pinkAccent, fontSize: 13)),
                          ),
                          const Padding(padding: EdgeInsets.only(left: 10))
                        ],
                      )),
                ),
              ),
              const Padding(padding: EdgeInsets.only(top: 10)),
              Text("相关推荐",
                  style: TextStyle(fontSize: 18.0, color: Colors.black)),
              GridView.builder(
                  physics: const NeverScrollableScrollPhysics(),
                  shrinkWrap: true,
                  gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 3,
                    mainAxisSpacing: 10,
                    crossAxisSpacing: 10,
                    childAspectRatio: 0.618,
                  ),
                  padding: const EdgeInsets.all(10),
                  itemCount: 12,
                  itemBuilder: (context, i) => const AnimeCard())
            ],
          ))
        ],
      ),
    );
  }
}

class _MediaPlayer extends StatefulWidget {
  const _MediaPlayer({super.key});

  @override
  State<_MediaPlayer> createState() => _MediaPlayerState();
}

class _MediaPlayerState extends State<_MediaPlayer> {
  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Expanded(
            child: AspectRatio(
          aspectRatio: 16 / 9,
          child: Image.asset("${Constant.ASSETS_IMG}img_banner.jpg",
              fit: BoxFit.cover),
        ))
      ],
    );
  }
}
